﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using DBUtility;
using gfLibrary;
using IYAKASAPortal.Services;
using BLL;
using System.Data;
using System.IO;
using Model;
using IYASAKAReport;

namespace IYAKASAPortal.PrintAll
{
    public class SetCRDataSource
    {

        #region 绑定综检报告单
        /// <summary>
        /// 绑定安检三轮车报告单
        /// </summary>
        /// <param name="strKey"></param>
        /// <param name="strPath"></param>
        /// <returns></returns>
        public ReportDocument BindSLCMTCAJ_ReportEx(string strKey, string strPath, bool bSingle)
        {
            ReportDocument document = new ReportDocument();
            document.Load(strPath);
            RESULT_VEHICLE_INFO_BLL bll = new RESULT_VEHICLE_INFO_BLL();
            var vehicleInfo = bll.GetModelList("ID=" + strKey);
            AJReport pqReport = new AJReport(vehicleInfo[0], bSingle);
            //pqReport.PassC = "○";
            //pqReport.FailC = "×";
            rpt.SLCMTCAJ ds = new rpt.SLCMTCAJ();

            ds = (rpt.SLCMTCAJ)pqReport.BindAJ_SLMT(ds);
            document.SetDataSource(ds);
            return document;
        }
      
        /// <summary>
        /// 绑定技术等级评定
        /// </summary>
        /// <param name="strKey"></param>
        /// <param name="strPath"></param>
        /// <param name="bSingle"></param>
        /// <returns></returns>
        public ReportDocument BindZJJSDJReportEx(string strKey, string strPath, bool bSingle)
        {
            ReportDocument document = new ReportDocument();
            document.Load(strPath);

            RESULT_VEHICLE_INFO_BLL bll = new RESULT_VEHICLE_INFO_BLL();
            var vehicleInfo = bll.GetModelList("ID=" + strKey);

            ZJReport zjReport = new ZJReport(vehicleInfo[0], bSingle);
            rpt.DsZJJSDJ ds = new rpt.DsZJJSDJ();

            zjReport.NoAudit = "//";
            zjReport.Level1 = "1";
            zjReport.Level2 = "2";
            zjReport.FailC = "×";
            zjReport.NoTest = "-";
            zjReport.PassC = "○";
            ds = (rpt.DsZJJSDJ)zjReport.GetJSDJPDResource(ds);

            document.SetDataSource(ds);

            return document;
        }

        /// <summary>
        /// 绑定综检报告单
        /// </summary>
        /// <param name="strKey"></param>
        /// <param name="strPath"></param>
        /// <param name="bSingle"></param>
        /// <returns></returns>
        public ReportDocument BindZJReportEx(string strKey, string strPath, bool bSingle)
        {
            ReportDocument document = new ReportDocument();
            document.Load(strPath);

            RESULT_VEHICLE_INFO_BLL bll = new RESULT_VEHICLE_INFO_BLL();
            var vehicleInfo = bll.GetModelList("ID=" + strKey);

            ZJReport zjReport = new ZJReport(vehicleInfo[0], bSingle);
            rpt.DsZJReport ds = new rpt.DsZJReport();
            zjReport.NoTest = "-";

            ds = (rpt.DsZJReport)zjReport.GetReportResource(ds);

            document.SetDataSource(ds);

            return document;
        }

        /// <summary>
        /// 绑定综检仪器报告单
        /// </summary>
        /// <param name="strKey"></param>
        /// <param name="strPath"></param>
        /// <param name="bSingle"></param>
        /// <returns></returns>
        public ReportDocument BindZJYQReportEx(string strKey, string strPath, bool bSingle)
        {
            ReportDocument document = new ReportDocument();
            document.Load(strPath);

            RESULT_VEHICLE_INFO_BLL bll = new RESULT_VEHICLE_INFO_BLL();
            var vehicleInfo = bll.GetModelList("ID=" + strKey);

            ZJReport zjReport = new ZJReport(vehicleInfo[0], bSingle);
            rpt.DsZJYQ ds = new rpt.DsZJYQ();

            zjReport.PassC = "○";
            zjReport.FailC = "×";
            zjReport.NoTest = "-";
            zjReport.Level1 = "1级";
            zjReport.Level2 = "2级";
            ds = (rpt.DsZJYQ)zjReport.GetYQResource(ds);

            document.SetDataSource(ds);

            return document;
        }

        /// <summary>
        /// 绑定综检人工报告单
        /// </summary>
        /// <param name="strKey"></param>
        /// <param name="strPath"></param>
        /// <param name="bSingle"></param>
        /// <returns></returns>
        public ReportDocument BindZJRGReportEx(string strKey, string strPath, bool bSingle)
        {
            ReportDocument document = new ReportDocument();
            document.Load(strPath);

            RESULT_VEHICLE_INFO_BLL bll = new RESULT_VEHICLE_INFO_BLL();
            var vehicleInfo = bll.GetModelList("ID=" + strKey);

            ZJReport zjReport = new ZJReport(vehicleInfo[0], bSingle);
            rpt.DsZJRG ds = new rpt.DsZJRG();

            zjReport.NoAudit = "//";
            zjReport.FailC = "×";
            zjReport.NoTest = "-";
            ds = (rpt.DsZJRG)zjReport.GetRGResource(ds);

            document.SetDataSource(ds);

            return document;
        }
        #endregion

        #region 绑定安检
        /// <summary>
        /// 绑定安检报告单
        /// </summary>
        /// <param name="strKey">ID</param>
        /// <param name="strPath">路径</param>
        /// <param name="bSingle">是不是单次打印</param>
        /// <returns>ReportDocument for AJ</returns>
        public ReportDocument BindAJReportEx(string strKey, string strPath, bool bSingle)
        {
            ReportDocument document = new ReportDocument();
            document.Load(strPath);

           

            RESULT_VEHICLE_INFO_BLL bll = new RESULT_VEHICLE_INFO_BLL();
            var vehicleInfo = bll.GetModelList("ID=" + strKey);

            AJReport ajReport = new AJReport(vehicleInfo[0], bSingle);
            rpt.DsAJ ds = new rpt.DsAJ();

            ajReport.bShowWKCCAndZBZL = true;

            ds = (rpt.DsAJ)ajReport.GetReportResource(ds);

            document.SetDataSource(ds);

            return document;
        }

        /// 绑定安检仪器报告单
        /// </summary>
        /// <param name="strKey"></param>
        /// <param name="strPath"></param>
        /// <returns></returns>
        public ReportDocument BindAJYQReportEx(string strKey, string strPath, bool bSingle)
        {
            RESULT_VEHICLE_INFO_BLL bll = new RESULT_VEHICLE_INFO_BLL();
            var vehicleInfo = bll.GetModelList("ID=" + strKey);

            ReportDocument document = new ReportDocument();
            document.Load(strPath);

            rpt.DsAJYQ ds = new rpt.DsAJYQ();
            AJReport ajReport = new AJReport(vehicleInfo[0], bSingle);
            ajReport.PassC = "○";
            ajReport.FailC = "×";
            ajReport.NoAudit = "-";
            ajReport.NoTest = "-";

            ds = (rpt.DsAJYQ)ajReport.BindReportSource_YQ(ds);

            document.SetDataSource(ds);
            return document;
        }

        /// <summary>
        /// 绑定安检人工报告单
        /// </summary>
        /// <param name="strKey"></param>
        /// <param name="strPath"></param>
        /// <param name="bSingle"></param>
        /// <returns></returns>
        public ReportDocument BindAJRGReportEx(string strKey, string strPath, bool bSingle)
        {
            ReportDocument document = new ReportDocument();
            document.Load(strPath);

            RESULT_VEHICLE_INFO_BLL bll = new RESULT_VEHICLE_INFO_BLL();
            var vehicleInfo = bll.GetModelList("ID=" + strKey);

            AJReport ajReport = new AJReport(vehicleInfo[0], bSingle);
            rpt.DsAJRG ds = new rpt.DsAJRG();
            ajReport.bShowWKCCAndZBZL = true;
            ds = (rpt.DsAJRG)ajReport.BindReportResource_RG(ds);

            document.SetDataSource(ds);
            return document;
        }
        #endregion
    }
}